package com.warmlight.voicepacket.utils;

import android.app.Activity;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.lzy.imagepicker.loader.ImageLoader;
import com.warmlight.voicepacket.R;

import java.io.File;

public class GlideImageLoader implements ImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        RequestOptions options = new RequestOptions();
        options.placeholder(R.drawable.image_placeholder).error(R.drawable.icon_roud_error);
        Glide.with(activity)
                .load(Uri.fromFile(new File(path)))
                .apply(options)
//                .error(R.drawable.icon_roud_error)
//                .placeholder(R.drawable.image_placeholder)
                .into(imageView);
    }

    @Override
    public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
        RequestOptions options = new RequestOptions();
        options.placeholder(R.drawable.image_placeholder).error(R.drawable.icon_roud_error);
        Glide.with(activity)
                .load(Uri.fromFile(new File(path)))
                .apply(options)
//                .error(R.drawable.icon_roud_error)
//                .placeholder(R.drawable.image_placeholder)
                .into(imageView);
    }

    @Override
    public void clearMemoryCache() {
    }
}